Skip to content

Conversation

@rjan90
Copy link
Contributor

@rjan90 rjan90 commented Sep 10, 2025

Fixes: filecoin-project/lotus#13329

Root Cause
SectorContentChangedParams was defined as a type alias []SectorChanges, but CBOR-gen doesn't automatically generate marshalling methods for slice type aliases.

Solution

  • Convert SectorContentChangedParams from type alias to proper type
  • Add SectorContentChangedParams to gen.go files for automatic generation
  • Regenerate CBOR marshalling methods using cbor-gen

…tateEncodeParams panic

fix: add CBOR marshalling for SectorContentChangedParams to prevent StateEncodeParams panic
chore: remove empty test-file
Copilot AI review requested due to automatic review settings September 10, 2025 13:23
@github-project-automation github-project-automation bot moved this to 📌 Triage in FilOz Sep 10, 2025
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a panic in the StateEncodeParams API when used with the Market Actor's SectorContentChanged method by addressing CBOR marshalling issues with slice type aliases. The root cause was that SectorContentChangedParams was defined as a type alias (= []SectorChanges) which doesn't automatically generate CBOR marshalling methods.

  • Convert SectorContentChangedParams from type alias to proper type definition
  • Implement manual MarshalCBOR and UnmarshalCBOR methods following existing codebase patterns
  • Add required imports (fmt, io) for CBOR operations

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
builtin/v17/miner/miner_types.go Convert type alias to proper type, add CBOR methods and imports
builtin/v16/miner/miner_types.go Convert type alias to proper type, add CBOR methods and imports
builtin/v15/miner/miner_types.go Convert type alias to proper type, add CBOR methods and imports
builtin/v14/miner/miner_types.go Convert type alias to proper type, add CBOR methods and imports
builtin/v13/miner/miner_types.go Convert type alias to proper type, add CBOR methods and imports

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@codecov-commenter
Copy link

codecov-commenter commented Sep 10, 2025

Codecov Report

❌ Patch coverage is 0% with 270 lines in your changes missing coverage. Please review.
✅ Project coverage is 3.60%. Comparing base (193a96c) to head (e0a69f5).

Files with missing lines Patch % Lines
builtin/v13/miner/cbor_gen.go 0.00% 53 Missing ⚠️
builtin/v14/miner/cbor_gen.go 0.00% 53 Missing ⚠️
builtin/v15/miner/cbor_gen.go 0.00% 53 Missing ⚠️
builtin/v16/miner/cbor_gen.go 0.00% 53 Missing ⚠️
builtin/v17/miner/cbor_gen.go 0.00% 53 Missing ⚠️
builtin/v13/gen/gen.go 0.00% 1 Missing ⚠️
builtin/v14/gen/gen.go 0.00% 1 Missing ⚠️
builtin/v15/gen/gen.go 0.00% 1 Missing ⚠️
builtin/v16/gen/gen.go 0.00% 1 Missing ⚠️
builtin/v17/gen/gen.go 0.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #411      +/-   ##
==========================================
- Coverage    3.60%    3.60%   -0.01%     
==========================================
  Files         733      733              
  Lines      199998   200268     +270     
==========================================
  Hits         7212     7212              
- Misses     190519   190789     +270     
  Partials     2267     2267              
Files with missing lines Coverage Δ
builtin/v13/miner/miner_types.go 0.00% <ø> (ø)
builtin/v14/miner/miner_types.go 0.00% <ø> (ø)
builtin/v15/miner/miner_types.go 0.00% <ø> (ø)
builtin/v16/miner/miner_types.go 0.00% <ø> (ø)
builtin/v17/miner/miner_types.go 0.00% <ø> (ø)
builtin/v13/gen/gen.go 0.00% <0.00%> (ø)
builtin/v14/gen/gen.go 0.00% <0.00%> (ø)
builtin/v15/gen/gen.go 0.00% <0.00%> (ø)
builtin/v16/gen/gen.go 0.00% <0.00%> (ø)
builtin/v17/gen/gen.go 0.00% <0.00%> (ø)
... and 5 more
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ZenGround0
Copy link
Contributor

Implement manual MarshalCBOR and UnmarshalCBOR methods

@rjan90 did you use cbor gen here? If not we should figure out how to get this done by cbor gen

@ZenGround0
Copy link
Contributor

Did you try adding the type here ? Is there an issue with following that approach?

@BigLep BigLep moved this from 📌 Triage to ⌨️ In Progress in FilOz Sep 10, 2025
@rvagg
Copy link
Member

rvagg commented Sep 11, 2025

should end up being a little similar to #378

@rjan90
Copy link
Contributor Author

rjan90 commented Sep 11, 2025

Thanks for the pointers both! Will update the PR and get it closer/more similar to #378

Fixes StateEncodeParams API panic when called with Market Actor's
SectorContentChanged method by adding SectorContentChangedParams to
cbor-gen for proper CBOR marshalling across actor versions v13-v17.

- Convert SectorContentChangedParams from type alias to proper type
- Add SectorContentChangedParams to gen.go files for automatic generation
- Regenerate CBOR marshalling methods using cbor-gen
@rjan90
Copy link
Contributor Author

rjan90 commented Sep 11, 2025

Okay, pushed some changes to make it look closer/similar to 378, as well as another round of testing, and can confirm that I now do not get any panics:

curl -X POST http://localhost:6655/rpc/v1 -H "Content-Type: application/json" -d '{"jsonrpc": "2.0", "method": "Filecoin.StateEncodeParams", "params": [{"/": "bafk2bzacebsn3npegbog3dytzvx6ewliykjkrzuzzrxphe3dmokbou3d4knt2"}, 2034386435, [{"Sector":1,"MinimumCommitmentEpoch":22,"Added":[{"Data":{"/":"baga6ea4seaqao7s73y24kcutaosvacpdjgfe5pw76ooefnyqw4ynr3d2y6x2mpq"},"Size":2048,"Payload":"EjRWeA=="}]}]], "id": 1}'
{"id":1,"jsonrpc":"2.0","result":"gYMBFoGD2CpYKAABgeIDkiAgB35f3jXFCpMDpVAJ40mKTr7f85xCtxC3MNjsesevpj4ZCABEEjRWeA=="}

Copy link
Contributor

@ZenGround0 ZenGround0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice looks great

@github-project-automation github-project-automation bot moved this from ⌨️ In Progress to ✔️ Approved by reviewer in FilOz Sep 11, 2025
@rjan90 rjan90 merged commit 5405f01 into master Sep 11, 2025
8 checks passed
@rjan90 rjan90 deleted the phi/cbor-marshalling-unmarshalling branch September 11, 2025 15:19
@github-project-automation github-project-automation bot moved this from ✔️ Approved by reviewer to 🎉 Done in FilOz Sep 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 🎉 Done

Development

Successfully merging this pull request may close these issues.

StateEncodeParams API panics with market actor method

5 participants